package com.strato.file.remote.v1_0_0.server.activator;

import java.util.HashMap;
import java.util.Map;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

import com.strato.base.osgi.v1_0_0.BundleUtil;
import com.strato.file.remote.v1_0_0.server.FileServer;

public class Activator implements BundleActivator {

	private static BundleContext context;
	
	@Override
	public void start(BundleContext arg0) throws Exception {
		context=arg0;
		for(Map<String, Object> props:createQueue.keySet()){
			BundleUtil.exportServices(arg0, createQueue.get(props), new Class<?>[]{FileServer.class}, props);
		}
	}

	@Override
	public void stop(BundleContext arg0) throws Exception {
		context=null;
	}

	public static BundleContext getContext() {
		return context;
	}

	private static Map<Map<String, Object>,FileServer> createQueue=new HashMap<>();
	
	public static void addToCreateQueue(Map<String, Object> props, FileServer server) {
		createQueue.put(props, server);
	}

}
